package chapter6;
import java.util.Scanner;

/****************************************************************
 * Author：icynlau
 * Description: MyTriangle   即exc6_19
 * Date:2021/4/4
 * ***************************************************************
 */
public class MyTriangle {
	
	public static void main(String[] args) {
		
		Scanner input=new Scanner(System.in);
		
		System.out.print("Enter three sides:  ");
		double s1=input.nextDouble();
		double s2=input.nextDouble();
		double s3=input.nextDouble();
		
		if(isValid(s1,s2,s3)) {
			
			System.out.print("The triangle's area is "+area(s1,s2,s3));
			
		}else {
			System.out.print("Invalid  Triangle.");
		}
		
	}
	
	public static boolean  isValid(
			double side1,double side2,double side3) {
		boolean ret=true;
		
		if(side1+side2<side3 ||side2+side3<side1 ||side1+side3<side2) {
			ret=false;
		}
		
		return ret;
	}
	
	public static double area(
			double side1,double side2,double side3) {
		
		double area=0.0;
		
		double s=0.5*(side1+side2+side3);
		
		area=Math.sqrt(s*(s-side1)*(s-side2)*(s-side3));
		
		return area;
		
	}
	
}
